<template>
  <el-aside :width=" $store.state.isCollapse ? '64px': '200px'">
    <el-menu
      :collapse="$store.state.isCollapse"
      :collapse-transition="false"
      :router="true"
      :default-active="route.fullPath"
    >
      <el-menu-item index="/index">
        <el-icon>
          <HomeFilled />
        </el-icon>
        <span>首页</span>
      </el-menu-item>
      <el-menu-item index="/center">
        <el-icon>
          <Avatar />
        </el-icon>
        <span>个人中心</span>
      </el-menu-item>
      <el-sub-menu index="/user-manage" v-admin>
        <template #title>
          <el-icon><User /></el-icon>
          <span>用户管理</span>
        </template>
        <el-menu-item index="/user-manage/useradd">添加用户</el-menu-item>
        <el-menu-item index="/user-manage/userlist">用户列表</el-menu-item>
      </el-sub-menu>
      <el-sub-menu index="/news-manage">
        <template #title>
          <el-icon><Message /></el-icon>
          <span>博客管理</span>
        </template>
        <el-menu-item index="/blog-manage/blogadd">创作博客</el-menu-item>
        <el-menu-item index="/blog-manage/bloglist">博客列表</el-menu-item>
      </el-sub-menu>
      <el-sub-menu index="/project-manage">
        <template #title>
          <el-icon><TakeawayBox /></el-icon>
          <span>项目管理</span>
        </template>
        <el-menu-item index="/project-manage/projectadd">添加项目</el-menu-item>
        <el-menu-item index="/project-manage/projectlist">项目列表</el-menu-item>
      </el-sub-menu>
    </el-menu>
  </el-aside>
</template>

<script setup>
import { HomeFilled, Avatar, User, Message, TakeawayBox } from '@element-plus/icons-vue'
import { useRoute } from 'vue-router'
import { useStore } from 'vuex';
const route = useRoute()
const store = useStore()
const vAdmin = {
  mounted(el) {
    if(store.state.userInfo.role !== 1) {
      el.parentNode.removeChild(el)
    }
  },
}
</script>


<style lang="scss" scoped>
.el-aside {
  height: 100vh;
  .el-menu {
    height: 100vh;
  }
}
</style>